<template>
  <div>
    <div ref="textEditor"></div>
  </div>
</template>

<script>
import Editor from "wangeditor";
export default {
  data() {
    return {
      editor: {}, // editor实例
    };
  },
  mounted() {
    this.editor = new Editor(this.$refs.textEditor);
    this.editor.config.height = 300;
    this.editor.config.focus = false;
    this.editor.config.onchange = (newHtml) => {
      // 通过自定义事件，把文本框中的内容传给父组件
      this.$emit('sendText', newHtml);
    };
    // 配置触发 onchange 的时间频率，默认为 200ms
    this.editor.create();
  },
};
</script>

<style lang="less" scoped></style>
